export const createBEM = (name: string) => {
  return (el?: string, mods?: Record<string, boolean>) => {
    let result = `${name}${el ? `__${el}` : ''}`

    if (mods) {
      const modStr = Object.keys(mods)
        .filter((mod) => mods[mod])
        .map((mod) => `${result}--${mod}`)
        .join('')
      result += modStr
    }
    return result
  }
}

export const createNameSpace = (name: string) => {
  const prefixdName = `op-${name}`
  return [prefixdName, createBEM(prefixdName)] as const
}
